<template>
  <div class="header">
    <div class="header-contain">
      <div class="logo">
        <img
          src="	https://www.miaoshoucdn.com/official/pc/img/hbIndex_logo.png"
          alt=""
        />
      </div>
      <div class="nav">
        <router-link
          :to="item.path"
          class="nav-item mouseover"
          v-for="(item, index) in navList"
          :key="index"
        >
          {{ item.name }}
          <ul class="solution" v-show="item.children && item.children.length">
            <li v-for="(Item, Index) in item.children" :key="Index">
              <router-link :to="Item.path">{{ Item.name }}</router-link>
            </li>
          </ul>
          <i class="nav-line"></i>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
// import { HeaderApi } from "@/api/api";
export default {
  data() {
    return {
      // navList: [],
    };
  },
  mounted() {
    // this.getHeaderList();
    this.$store.dispatch("he/AheaderApi");
  },
  computed: {
    ...mapState({
      navList: (state) => {
        return state.he.navList;
      },
    }),
  },
  methods: {
    // getHeaderList() {
    //   // console.log(111);
    //   HeaderApi.headerList().then((res) => {
    //     // console.log(res.data);
    //     this.navList = res.data.list;
    //   });
    // },
  },
};
</script>

<style scoped lang="less">
.header {
  width: 100%;
  background-color: #4c8de9;
  height: 98px;
  color: aliceblue;
}
.header-contain {
  width: 1204px;
  margin: 0 auto;
}
.logo {
  width: 171px;
  height: 45px;
  display: block;
  float: left;
  margin-top: 8px;
  img {
    width: 100px;
    margin-top: 32px;
  }
}
.nav {
  float: right;
  width: auto;
  height: 98px;
  line-height: 98px;
  z-index: 99;
  .nav-item {
    font-size: 16px;
    float: left;
    margin-right: 27px;
    position: relative;
    color: aliceblue;
    .solution {
      width: 100px;
      display: flex;
      flex-direction: column;
      position: absolute;
      left: -15px;
      opacity: 0;
      li {
        width: 100%;
        line-height: 30px;
        margin-right: 8px;
        background-color: rgba(6, 9, 52, 0.4);
        margin-top: 4px;
        a {
          color: aliceblue;
        }
      }
    }
  }
  .mouseover:hover .solution {
    opacity: 100%;
  }
}

.nav .active .nav-line {
  display: block;
  position: absolute;
  bottom: 25px;
  width: 30px;
  height: 1px;
  text-align: center;
  background-color: aliceblue;
  left: 50%;
  transform: translateX(-50%);
}
.nav:hover {
  cursor: pointer;
}
</style>